package com.fsnbigdata.domain;
import org.hibernate.validator.constraints.Length;
import org.springframework.roo.addon.javabean.annotations.RooEquals;
import org.springframework.roo.addon.javabean.annotations.RooJavaBean;
import org.springframework.roo.addon.javabean.annotations.RooToString;
import org.springframework.roo.addon.jpa.annotations.entity.RooJpaEntity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
import io.springlets.format.EntityFormat;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import java.util.Objects;
import javax.persistence.Entity;

/**
 * = Germplasm
 *
 * TODO Auto-generated class documentation
 *
 */
@RooJavaBean
@RooToString
@RooJpaEntity
@RooEquals(isJpaEntity = true)
@Entity
@EntityFormat
public class Germplasm {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Version
    private Integer version;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @EntityFormat
    private Organism organism;

    /**
     * 保藏号
     */
    @Length(min = 0, max = 255,message ="保藏号信息内容长度必须在0-255个字符之间")
    private String preserveNo;

    /**
     * 单位
     */
    @Length(min = 0, max = 255,message ="单位信息内容长度必须在0-255个字符之间")
    private String unit;

    /**
     * 课题负责人
     */
    @Length(min = 0, max = 255,message ="课题负责人信息内容长度必须在0-255个字符之间")
    private String owner;

    /**
     * 采集编号
     */
    @Length(min = 0, max = 255,message ="采集编号信息内容长度必须在0-255个字符之间")
    private String collectNo;

    /**
     * 采集人
     */
    @Length(min = 0, max = 255,message ="采集人信息内容长度必须在0-255个字符之间")
    private String collector;

    /**
     * 采集时间
     */
    @Length(min = 0, max = 255,message ="采集时间信息内容长度必须在0-255个字符之间")
    private String collectDate;

    /**
     * 采集地点
     */
    @Length(min = 0, max = 255,message ="采集地点信息内容长度必须在0-255个字符之间")
    private String collectLocation;

    /**
     * 采集资源类型
     */
    @Length(min = 0, max = 255,message ="采集资源类型信息内容长度必须在0-255个字符之间")
    private String resourceType;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";

    /**
     * This `equals` implementation is specific for JPA entities and uses
     * the entity identifier for it, following the article in
     * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
     *
     * @param obj
     * @return Boolean
     */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        // instanceof is false if the instance is null
        if (!(obj instanceof Germplasm)) {
            return false;
        }
        return getId() != null && Objects.equals(getId(), ((Germplasm) obj).getId());
    }

    /**
     * This `hashCode` implementation is specific for JPA entities and uses a fixed `int` value to be able
     * to identify the entity in collections after a new id is assigned to the entity, following the article in
     * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
     *
     * @return Integer
     */
    public int hashCode() {
        return 31;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Long
     */
    public Long getId() {
        return this.id;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Integer
     */
    public Integer getVersion() {
        return this.version;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param version
     */
    public void setVersion(Integer version) {
        this.version = version;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Organism
     */
    public Organism getOrganism() {
        return this.organism;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param organism
     */
    public void setOrganism(Organism organism) {
        this.organism = organism;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getPreserveNo() {
        return this.preserveNo;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param preserveNo
     */
    public void setPreserveNo(String preserveNo) {
        this.preserveNo = preserveNo;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getUnit() {
        return this.unit;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param unit
     */
    public void setUnit(String unit) {
        this.unit = unit;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getOwner() {
        return this.owner;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param owner
     */
    public void setOwner(String owner) {
        this.owner = owner;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectNo() {
        return this.collectNo;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectNo
     */
    public void setCollectNo(String collectNo) {
        this.collectNo = collectNo;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollector() {
        return this.collector;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collector
     */
    public void setCollector(String collector) {
        this.collector = collector;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectDate() {
        return this.collectDate;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectDate
     */
    public void setCollectDate(String collectDate) {
        this.collectDate = collectDate;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectLocation() {
        return this.collectLocation;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectLocation
     */
    public void setCollectLocation(String collectLocation) {
        this.collectLocation = collectLocation;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getResourceType() {
        return this.resourceType;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param resourceType
     */
    public void setResourceType(String resourceType) {
        this.resourceType = resourceType;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String toString() {
        return "Germplasm {" + "id='" + id + '\'' + ", version='" + version + '\'' + ", preserveNo='" + preserveNo + '\'' + ", unit='" + unit + '\'' + ", owner='" + owner + '\'' + ", collectNo='" + collectNo + '\'' + ", collector='" + collector + '\'' + ", collectDate='" + collectDate + '\'' + ", collectLocation='" + collectLocation + '\'' + ", resourceType='" + resourceType + '\'' + ", ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE + '\'' + ", ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE + '\'' + "}" + super.toString();
    }
}
